package JavaSE.demoSE789;


class Animal1{
    private String name;
    private int age;


    public Animal1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void eat(){
        System.out.println(name+"正在吃饭!");
    }

}
class Cat extends Animal1{

    public String hear;

    public Cat(String name, int age, String hear) {
        super(name, age);
        this.hear = hear;
    }

    public void mew(){
        System.out.println(this.getName()+"咪咪正在发春!");
    }

    public void eat(){
        System.out.println(this.getName()+"正在吃猫粮!");
    }

}

public class TestOne {


    public static void main(String[] args) {
        Animal1 animal1 = new Cat("mimi",19,"blue");
        animal1.setName("mimi");
        animal1.eat();
    }


    /**
     * 多态前提--向上转型-----3种
     * @param animal1
     */

    //2、方法参数
    public static void mew(Animal1 animal1){

    }
    //3、方法返回值
    public static Animal1 mew2(){
        return new Cat("mimi",19,"blue");
    }



    public static void main3(String[] args) {
        Cat cat = new Cat("mimi",19,"blue");
        mew(cat);
        mew(new Cat("mimi",19,"blue"));
    }
//1、直接赋值
    public static void main2(String[] args) {
        Animal1 animal1 = new Cat("mimi",19,"blue");
        animal1.eat();

    }


    public static void main1(String[] args) {
        Cat cat1 = new Cat("咪咪",19,"blue");
        cat1.setName("咪咪");
        cat1.mew();
        cat1.eat();
    }
}
